package hu.xydan;
/**
 * @author wuxort
 */
import java.awt.*;
import java.awt.event.*;
import java.awt.event.KeyListener;
import javax.swing.*;
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.awt.GLCanvas;
import javax.media.opengl.glu.GLU;
import com.jogamp.opengl.util.FPSAnimator;
import java.io.IOException;
import static javax.media.opengl.GL.*;  // GL konstansok
import static javax.media.opengl.GL2.*; // GL2 konstansok

@SuppressWarnings("serial")
public class Xydan 
{ 
   private static String VERZIÓ = "0.0.1"; 
    
   private static String CÍM = "Alap motor " + VERZIÓ;
   private static final int FELBONTAS_SZELESSEG = 1024; 
   private static final int FELBONTAS_MAGASSAG = 768; 
   private static final int FPS = 60; 
   
   public static void main(String[] args) {
      
      SwingUtilities.invokeLater(new Runnable() {
         @Override
         public void run() {

            GLCanvas canvas = new OpenGL_init();
            canvas.setPreferredSize(new Dimension(FELBONTAS_SZELESSEG, FELBONTAS_MAGASSAG));
            
            final FPSAnimator animator = new FPSAnimator(canvas, FPS, true);
            
            final JFrame frame = new JFrame(); 
            frame.getContentPane().add(canvas);
            frame.addWindowListener(new WindowAdapter() 
            {
               @Override 
               public void windowClosing(WindowEvent e) 
               {
                  new Thread() 
                  {
                     @Override 
                     public void run() 
                     {
                        if (animator.isStarted()) animator.stop();
                        System.exit(0);
                     }
                  }.start();
               }
            });
            frame.setTitle(CÍM);
            frame.pack();
            frame.setVisible(true);
            animator.start(); // főciklus
         }
      });
   } 
}